/**
 *
 */
import Util;
import OSS;
import OpenPlatform;
import OSSUtil;
import FileForm;
import Number;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  checkConfig(config);
  @endpoint = getEndpoint('videoenhan', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AbstractEcommerceVideoRequest {
  duration?: float(name='Duration', description='This parameter is required.', example='5'),
  height?: int32(name='Height', example='480'),
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AbstractEcommerceVideo/AbstractEcommerceVideo1.mp4'),
  width?: int32(name='Width', example='480'),
}

model AbstractEcommerceVideoAdvanceRequest {
  duration?: float(name='Duration', description='This parameter is required.', example='5'),
  height?: int32(name='Height', example='480'),
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AbstractEcommerceVideo/AbstractEcommerceVideo1.mp4'),
  width?: int32(name='Width', example='480'),
}

model AbstractEcommerceVideoResponseBody = {
  data?: {
    videoCoverUrl?: string(name='VideoCoverUrl', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/shop-video-abs/2020-03-20-19/YVgDynxB.jpg?Expires=1584707249&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=e5Q3O%2ByA6H7UhYJeMZxz4p70de****'),
    videoUrl?: string(name='VideoUrl', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/shop-video-abs/2020-03-20-19/YVgDynxB.mp4?Expires=1584707249&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=KErufmbHvTUYYLRj6i42wY7Tew****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='50B33B81-CCB8-42BC-8A73-AC838618936E'),
}

model AbstractEcommerceVideoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AbstractEcommerceVideoResponseBody(name='body'),
}

/**
 * @param request AbstractEcommerceVideoRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AbstractEcommerceVideoResponse
 */
async function abstractEcommerceVideoWithOptions(request: AbstractEcommerceVideoRequest, runtime: Util.RuntimeOptions): AbstractEcommerceVideoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.duration)) {
    body['Duration'] = request.duration;
  }
  if (!Util.isUnset(request.height)) {
    body['Height'] = request.height;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  if (!Util.isUnset(request.width)) {
    body['Width'] = request.width;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AbstractEcommerceVideo',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request AbstractEcommerceVideoRequest
 * @return AbstractEcommerceVideoResponse
 */
async function abstractEcommerceVideo(request: AbstractEcommerceVideoRequest): AbstractEcommerceVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return abstractEcommerceVideoWithOptions(request, runtime);
}

async function abstractEcommerceVideoAdvance(request: AbstractEcommerceVideoAdvanceRequest, runtime: Util.RuntimeOptions): AbstractEcommerceVideoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var abstractEcommerceVideoReq = new AbstractEcommerceVideoRequest{};
  OpenApiUtil.convert(request, abstractEcommerceVideoReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    abstractEcommerceVideoReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var abstractEcommerceVideoResp = abstractEcommerceVideoWithOptions(abstractEcommerceVideoReq, runtime);
  return abstractEcommerceVideoResp;
}

model AbstractFilmVideoRequest {
  length?: int32(name='Length', description='This parameter is required.', example='5'),
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AbstractFilmVideo/AbstractFilmVideo1.mp4'),
}

model AbstractFilmVideoAdvanceRequest {
  length?: int32(name='Length', description='This parameter is required.', example='5'),
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AbstractFilmVideo/AbstractFilmVideo1.mp4'),
}

model AbstractFilmVideoResponseBody = {
  data?: {
    videoUrl?: string(name='VideoUrl', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/film-summary/EA61D012-5F89-4102-931E-419158BE2ADA_gb27k00.mp4?Expires=1584707613&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=weTexlBR1wmQlAhuU2JXaE7AyJ****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='9A5B872B-1BF0-4D84-90DA-A2EE1F072B82'),
}

model AbstractFilmVideoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AbstractFilmVideoResponseBody(name='body'),
}

/**
 * @param request AbstractFilmVideoRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AbstractFilmVideoResponse
 */
async function abstractFilmVideoWithOptions(request: AbstractFilmVideoRequest, runtime: Util.RuntimeOptions): AbstractFilmVideoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.length)) {
    body['Length'] = request.length;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AbstractFilmVideo',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request AbstractFilmVideoRequest
 * @return AbstractFilmVideoResponse
 */
async function abstractFilmVideo(request: AbstractFilmVideoRequest): AbstractFilmVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return abstractFilmVideoWithOptions(request, runtime);
}

async function abstractFilmVideoAdvance(request: AbstractFilmVideoAdvanceRequest, runtime: Util.RuntimeOptions): AbstractFilmVideoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var abstractFilmVideoReq = new AbstractFilmVideoRequest{};
  OpenApiUtil.convert(request, abstractFilmVideoReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    abstractFilmVideoReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var abstractFilmVideoResp = abstractFilmVideoWithOptions(abstractFilmVideoReq, runtime);
  return abstractFilmVideoResp;
}

model AddFaceVideoTemplateRequest {
  videoScene?: string(name='VideoScene'),
  videoURL?: string(name='VideoURL', description='This parameter is required.', example='http://invi-label.oss-cn-shanghai.aliyuncs.com/labl/temp/faceswap/test_for_api/xxxx.mp4'),
}

model AddFaceVideoTemplateAdvanceRequest {
  videoScene?: string(name='VideoScene'),
  videoURLObject?: readable(name='VideoURL', description='This parameter is required.', example='http://invi-label.oss-cn-shanghai.aliyuncs.com/labl/temp/faceswap/test_for_api/xxxx.mp4'),
}

model AddFaceVideoTemplateResponseBody = {
  date?: {
    faceInfos?: [ 
      {
        templateFaceID?: string(name='TemplateFaceID'),
        templateFaceURL?: string(name='TemplateFaceURL'),
      }
    ](name='FaceInfos'),
    templateId?: string(name='TemplateId', example='6cd509ea-54fa-4730-8e9d-c94cadcda048'),
    transResult?: string(name='TransResult'),
  }(name='Date'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='F61182AE-515B-5B0A-A877-1C9AE908FF15'),
}

model AddFaceVideoTemplateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AddFaceVideoTemplateResponseBody(name='body'),
}

/**
 * @summary 视频人脸融合模板增加
 *
 * @param request AddFaceVideoTemplateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AddFaceVideoTemplateResponse
 */
async function addFaceVideoTemplateWithOptions(request: AddFaceVideoTemplateRequest, runtime: Util.RuntimeOptions): AddFaceVideoTemplateResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.videoScene)) {
    body['VideoScene'] = request.videoScene;
  }
  if (!Util.isUnset(request.videoURL)) {
    body['VideoURL'] = request.videoURL;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddFaceVideoTemplate',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 视频人脸融合模板增加
 *
 * @param request AddFaceVideoTemplateRequest
 * @return AddFaceVideoTemplateResponse
 */
async function addFaceVideoTemplate(request: AddFaceVideoTemplateRequest): AddFaceVideoTemplateResponse {
  var runtime = new Util.RuntimeOptions{};
  return addFaceVideoTemplateWithOptions(request, runtime);
}

async function addFaceVideoTemplateAdvance(request: AddFaceVideoTemplateAdvanceRequest, runtime: Util.RuntimeOptions): AddFaceVideoTemplateResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var addFaceVideoTemplateReq = new AddFaceVideoTemplateRequest{};
  OpenApiUtil.convert(request, addFaceVideoTemplateReq);

  if(!Util.isUnset(request.videoURLObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoURLObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    addFaceVideoTemplateReq.videoURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var addFaceVideoTemplateResp = addFaceVideoTemplateWithOptions(addFaceVideoTemplateReq, runtime);
  return addFaceVideoTemplateResp;
}

model AdjustVideoColorRequest {
  mode?: string(name='Mode', example='LogC'),
  videoBitrate?: long(name='VideoBitrate', example='20'),
  videoCodec?: string(name='VideoCodec', example='h264'),
  videoFormat?: string(name='VideoFormat', example='mp4'),
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AdjustVideoColor/AdjustVideoColor1.mp4'),
}

model AdjustVideoColorAdvanceRequest {
  mode?: string(name='Mode', example='LogC'),
  videoBitrate?: long(name='VideoBitrate', example='20'),
  videoCodec?: string(name='VideoCodec', example='h264'),
  videoFormat?: string(name='VideoFormat', example='mp4'),
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/AdjustVideoColor/AdjustVideoColor1.mp4'),
}

model AdjustVideoColorResponseBody = {
  data?: {
    videoUrl?: string(name='VideoUrl', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/video-recolor/2021-01-21-07/46%3A05-test.mov?Expires=1611216966&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=icKn5gEQ6rNlSHmCi2zAf2tC0L****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='C4EB5E0B-0718-42CC-9B2C-1FB149256874'),
}

model AdjustVideoColorResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AdjustVideoColorResponseBody(name='body'),
}

/**
 * @param request AdjustVideoColorRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return AdjustVideoColorResponse
 */
async function adjustVideoColorWithOptions(request: AdjustVideoColorRequest, runtime: Util.RuntimeOptions): AdjustVideoColorResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.mode)) {
    body['Mode'] = request.mode;
  }
  if (!Util.isUnset(request.videoBitrate)) {
    body['VideoBitrate'] = request.videoBitrate;
  }
  if (!Util.isUnset(request.videoCodec)) {
    body['VideoCodec'] = request.videoCodec;
  }
  if (!Util.isUnset(request.videoFormat)) {
    body['VideoFormat'] = request.videoFormat;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AdjustVideoColor',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request AdjustVideoColorRequest
 * @return AdjustVideoColorResponse
 */
async function adjustVideoColor(request: AdjustVideoColorRequest): AdjustVideoColorResponse {
  var runtime = new Util.RuntimeOptions{};
  return adjustVideoColorWithOptions(request, runtime);
}

async function adjustVideoColorAdvance(request: AdjustVideoColorAdvanceRequest, runtime: Util.RuntimeOptions): AdjustVideoColorResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var adjustVideoColorReq = new AdjustVideoColorRequest{};
  OpenApiUtil.convert(request, adjustVideoColorReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    adjustVideoColorReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var adjustVideoColorResp = adjustVideoColorWithOptions(adjustVideoColorReq, runtime);
  return adjustVideoColorResp;
}

model ChangeVideoSizeRequest {
  b?: int32(name='B', example='0'),
  cropType?: string(name='CropType', example='smart'),
  fillType?: string(name='FillType', example='image'),
  g?: int32(name='G', example='0'),
  height?: int32(name='Height', description='This parameter is required.', example='1000'),
  r?: int32(name='R', example='0'),
  tightness?: float(name='Tightness', example='0.5'),
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/ChangeVideoSize/ChangeVideoSize1.mp4'),
  width?: int32(name='Width', description='This parameter is required.', example='600'),
}

model ChangeVideoSizeAdvanceRequest {
  b?: int32(name='B', example='0'),
  cropType?: string(name='CropType', example='smart'),
  fillType?: string(name='FillType', example='image'),
  g?: int32(name='G', example='0'),
  height?: int32(name='Height', description='This parameter is required.', example='1000'),
  r?: int32(name='R', example='0'),
  tightness?: float(name='Tightness', example='0.5'),
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/ChangeVideoSize/ChangeVideoSize1.mp4'),
  width?: int32(name='Width', description='This parameter is required.', example='600'),
}

model ChangeVideoSizeResponseBody = {
  data?: {
    videoCoverUrl?: string(name='VideoCoverUrl', example='http://vibktprfx-prod-prod-aic-vd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/video-crop/2020-07-24-20/ZTZslWcU.jpg?Expires=1595597077&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=5cq1NNBEzS64U7RTXRBGlo7WPy****'),
    videoUrl?: string(name='VideoUrl', example='http://vibktprfx-prod-prod-aic-vd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/video-crop/2020-07-24-20/ZTZslWcU.mp4?Expires=1595597077&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=ZyvD9AXCT2IUFkVJngQdbXMwX6****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='C00C5A32-9F54-44F0-9778-0968DD9BF22A'),
}

model ChangeVideoSizeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ChangeVideoSizeResponseBody(name='body'),
}

/**
 * @param request ChangeVideoSizeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ChangeVideoSizeResponse
 */
async function changeVideoSizeWithOptions(request: ChangeVideoSizeRequest, runtime: Util.RuntimeOptions): ChangeVideoSizeResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.b)) {
    body['B'] = request.b;
  }
  if (!Util.isUnset(request.cropType)) {
    body['CropType'] = request.cropType;
  }
  if (!Util.isUnset(request.fillType)) {
    body['FillType'] = request.fillType;
  }
  if (!Util.isUnset(request.g)) {
    body['G'] = request.g;
  }
  if (!Util.isUnset(request.height)) {
    body['Height'] = request.height;
  }
  if (!Util.isUnset(request.r)) {
    body['R'] = request.r;
  }
  if (!Util.isUnset(request.tightness)) {
    body['Tightness'] = request.tightness;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  if (!Util.isUnset(request.width)) {
    body['Width'] = request.width;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ChangeVideoSize',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request ChangeVideoSizeRequest
 * @return ChangeVideoSizeResponse
 */
async function changeVideoSize(request: ChangeVideoSizeRequest): ChangeVideoSizeResponse {
  var runtime = new Util.RuntimeOptions{};
  return changeVideoSizeWithOptions(request, runtime);
}

async function changeVideoSizeAdvance(request: ChangeVideoSizeAdvanceRequest, runtime: Util.RuntimeOptions): ChangeVideoSizeResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var changeVideoSizeReq = new ChangeVideoSizeRequest{};
  OpenApiUtil.convert(request, changeVideoSizeReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    changeVideoSizeReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var changeVideoSizeResp = changeVideoSizeWithOptions(changeVideoSizeReq, runtime);
  return changeVideoSizeResp;
}

model ConvertHdrVideoRequest {
  bitrate?: int32(name='Bitrate', example='30'),
  HDRFormat?: string(name='HDRFormat', example='HLG'),
  maxIlluminance?: int32(name='MaxIlluminance', example='1000'),
  videoURL?: string(name='VideoURL', description='This parameter is required.', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/test_for_api/xxxx.mp4'),
}

model ConvertHdrVideoAdvanceRequest {
  bitrate?: int32(name='Bitrate', example='30'),
  HDRFormat?: string(name='HDRFormat', example='HLG'),
  maxIlluminance?: int32(name='MaxIlluminance', example='1000'),
  videoURLObject?: readable(name='VideoURL', description='This parameter is required.', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/test_for_api/xxxx.mp4'),
}

model ConvertHdrVideoResponseBody = {
  data?: {
    videoURL?: string(name='VideoURL', example='http://vibktprfx-prod-prod-aic-vd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/hdr-enhance/20-12-22/HaKDdTI48i2GQGy7_20-12-22-06-42-45.mp4?Expires=1608621178&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=SWc90T0JHg5eWc64x8GmYHKsvX****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='E0CF495F-E806-4B9C-B204-E1230608239D'),
}

model ConvertHdrVideoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ConvertHdrVideoResponseBody(name='body'),
}

/**
 * @param request ConvertHdrVideoRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ConvertHdrVideoResponse
 */
async function convertHdrVideoWithOptions(request: ConvertHdrVideoRequest, runtime: Util.RuntimeOptions): ConvertHdrVideoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.bitrate)) {
    body['Bitrate'] = request.bitrate;
  }
  if (!Util.isUnset(request.HDRFormat)) {
    body['HDRFormat'] = request.HDRFormat;
  }
  if (!Util.isUnset(request.maxIlluminance)) {
    body['MaxIlluminance'] = request.maxIlluminance;
  }
  if (!Util.isUnset(request.videoURL)) {
    body['VideoURL'] = request.videoURL;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ConvertHdrVideo',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request ConvertHdrVideoRequest
 * @return ConvertHdrVideoResponse
 */
async function convertHdrVideo(request: ConvertHdrVideoRequest): ConvertHdrVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return convertHdrVideoWithOptions(request, runtime);
}

async function convertHdrVideoAdvance(request: ConvertHdrVideoAdvanceRequest, runtime: Util.RuntimeOptions): ConvertHdrVideoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var convertHdrVideoReq = new ConvertHdrVideoRequest{};
  OpenApiUtil.convert(request, convertHdrVideoReq);

  if(!Util.isUnset(request.videoURLObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoURLObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    convertHdrVideoReq.videoURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var convertHdrVideoResp = convertHdrVideoWithOptions(convertHdrVideoReq, runtime);
  return convertHdrVideoResp;
}

model DeleteFaceVideoTemplateRequest {
  templateId?: string(name='TemplateId', description='This parameter is required.', example='3bf2418c-7adf-4002-a9d6-2f7cf1889c0d'),
}

model DeleteFaceVideoTemplateResponseBody = {
  requestId?: string(name='RequestId', example='2337D184-CD63-57B5-96A2-B60AABCB7B58'),
}

model DeleteFaceVideoTemplateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteFaceVideoTemplateResponseBody(name='body'),
}

/**
 * @summary 视频人脸融合模板删除
 *
 * @param request DeleteFaceVideoTemplateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteFaceVideoTemplateResponse
 */
async function deleteFaceVideoTemplateWithOptions(request: DeleteFaceVideoTemplateRequest, runtime: Util.RuntimeOptions): DeleteFaceVideoTemplateResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.templateId)) {
    body['TemplateId'] = request.templateId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteFaceVideoTemplate',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 视频人脸融合模板删除
 *
 * @param request DeleteFaceVideoTemplateRequest
 * @return DeleteFaceVideoTemplateResponse
 */
async function deleteFaceVideoTemplate(request: DeleteFaceVideoTemplateRequest): DeleteFaceVideoTemplateResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteFaceVideoTemplateWithOptions(request, runtime);
}

model EnhancePortraitVideoRequest {
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxx/shang/video/SD%289516100%29.mp4'),
}

model EnhancePortraitVideoAdvanceRequest {
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxx/shang/video/SD%289516100%29.mp4'),
}

model EnhancePortraitVideoResponseBody = {
  data?: {
    videoUrl?: string(name='VideoUrl', example='http://vibktprfx-prod-prod-xstream-cn-shanghai.oss-cn-shanghai.aliyuncs.com/xstream-framework/upload_result_video_2023-02-10_09.45.55.mp4?Expires=1675995564&amp;OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&amp;Signature=aIXTeM4IU4nARjy3SNA3YGhhqj****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='d21a2afa-4d52-4bca-803b-e65028146603'),
}

model EnhancePortraitVideoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EnhancePortraitVideoResponseBody(name='body'),
}

/**
 * @summary 视频人像增强
 *
 * @param request EnhancePortraitVideoRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return EnhancePortraitVideoResponse
 */
async function enhancePortraitVideoWithOptions(request: EnhancePortraitVideoRequest, runtime: Util.RuntimeOptions): EnhancePortraitVideoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'EnhancePortraitVideo',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 视频人像增强
 *
 * @param request EnhancePortraitVideoRequest
 * @return EnhancePortraitVideoResponse
 */
async function enhancePortraitVideo(request: EnhancePortraitVideoRequest): EnhancePortraitVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return enhancePortraitVideoWithOptions(request, runtime);
}

async function enhancePortraitVideoAdvance(request: EnhancePortraitVideoAdvanceRequest, runtime: Util.RuntimeOptions): EnhancePortraitVideoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var enhancePortraitVideoReq = new EnhancePortraitVideoRequest{};
  OpenApiUtil.convert(request, enhancePortraitVideoReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    enhancePortraitVideoReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var enhancePortraitVideoResp = enhancePortraitVideoWithOptions(enhancePortraitVideoReq, runtime);
  return enhancePortraitVideoResp;
}

model EnhanceVideoQualityRequest {
  bitrate?: int32(name='Bitrate', example='20'),
  frameRate?: int32(name='FrameRate', example='50'),
  HDRFormat?: string(name='HDRFormat', example='PQ'),
  maxIlluminance?: int32(name='MaxIlluminance', example='600'),
  outPutHeight?: int32(name='OutPutHeight', example='200'),
  outPutWidth?: int32(name='OutPutWidth', example='200'),
  videoURL?: string(name='VideoURL', description='This parameter is required.', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/test_for_api/xxxx.mp4'),
}

model EnhanceVideoQualityAdvanceRequest {
  bitrate?: int32(name='Bitrate', example='20'),
  frameRate?: int32(name='FrameRate', example='50'),
  HDRFormat?: string(name='HDRFormat', example='PQ'),
  maxIlluminance?: int32(name='MaxIlluminance', example='600'),
  outPutHeight?: int32(name='OutPutHeight', example='200'),
  outPutWidth?: int32(name='OutPutWidth', example='200'),
  videoURLObject?: readable(name='VideoURL', description='This parameter is required.', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/test_for_api/xxxx.mp4'),
}

model EnhanceVideoQualityResponseBody = {
  data?: {
    videoURL?: string(name='VideoURL', example='http://vibktprfx-prod-prod-aic-vd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/uhd-enhance/20-11-20/Wwzf9z75GO5XdisS_20-11-20-07-13-48.mp4?Expires=1605858272&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=vvY0D%2Bl5eEzp%2BD7mPOWz0zMU7v****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='881F39DC-C107-4817-A6D5-000BE833CC2A'),
}

model EnhanceVideoQualityResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EnhanceVideoQualityResponseBody(name='body'),
}

/**
 * @param request EnhanceVideoQualityRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return EnhanceVideoQualityResponse
 */
async function enhanceVideoQualityWithOptions(request: EnhanceVideoQualityRequest, runtime: Util.RuntimeOptions): EnhanceVideoQualityResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.bitrate)) {
    body['Bitrate'] = request.bitrate;
  }
  if (!Util.isUnset(request.frameRate)) {
    body['FrameRate'] = request.frameRate;
  }
  if (!Util.isUnset(request.HDRFormat)) {
    body['HDRFormat'] = request.HDRFormat;
  }
  if (!Util.isUnset(request.maxIlluminance)) {
    body['MaxIlluminance'] = request.maxIlluminance;
  }
  if (!Util.isUnset(request.outPutHeight)) {
    body['OutPutHeight'] = request.outPutHeight;
  }
  if (!Util.isUnset(request.outPutWidth)) {
    body['OutPutWidth'] = request.outPutWidth;
  }
  if (!Util.isUnset(request.videoURL)) {
    body['VideoURL'] = request.videoURL;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'EnhanceVideoQuality',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request EnhanceVideoQualityRequest
 * @return EnhanceVideoQualityResponse
 */
async function enhanceVideoQuality(request: EnhanceVideoQualityRequest): EnhanceVideoQualityResponse {
  var runtime = new Util.RuntimeOptions{};
  return enhanceVideoQualityWithOptions(request, runtime);
}

async function enhanceVideoQualityAdvance(request: EnhanceVideoQualityAdvanceRequest, runtime: Util.RuntimeOptions): EnhanceVideoQualityResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var enhanceVideoQualityReq = new EnhanceVideoQualityRequest{};
  OpenApiUtil.convert(request, enhanceVideoQualityReq);

  if(!Util.isUnset(request.videoURLObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoURLObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    enhanceVideoQualityReq.videoURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var enhanceVideoQualityResp = enhanceVideoQualityWithOptions(enhanceVideoQualityReq, runtime);
  return enhanceVideoQualityResp;
}

model EraseVideoLogoRequest {
  boxes?: [ 
    {
      h?: float(name='H', example='1.0'),
      w?: float(name='W', example='1.0'),
      x?: float(name='X', example='0.0'),
      y?: float(name='Y', example='0.0'),
    }
  ](name='Boxes'),
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoLogo/EraseVideoLogo1.mp4'),
}

model EraseVideoLogoAdvanceRequest {
  boxes?: [ 
    {
      h?: float(name='H', example='1.0'),
      w?: float(name='W', example='1.0'),
      x?: float(name='X', example='0.0'),
      y?: float(name='Y', example='0.0'),
    }
  ](name='Boxes'),
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoLogo/EraseVideoLogo1.mp4'),
}

model EraseVideoLogoResponseBody = {
  data?: {
    videoUrl?: string(name='VideoUrl', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/video-delogo/2020-03-20-11/53%3A56-DGNUGG7AcRlAylhr.mp4?Expires=1584707036&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=7CvsX7X1rSU%2B%2FDxnw484lb3LCD****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='95532F36-98FC-4DCD-815C-282BB26D2DA1'),
}

model EraseVideoLogoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EraseVideoLogoResponseBody(name='body'),
}

/**
 * @param request EraseVideoLogoRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return EraseVideoLogoResponse
 */
async function eraseVideoLogoWithOptions(request: EraseVideoLogoRequest, runtime: Util.RuntimeOptions): EraseVideoLogoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.boxes)) {
    body['Boxes'] = request.boxes;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'EraseVideoLogo',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request EraseVideoLogoRequest
 * @return EraseVideoLogoResponse
 */
async function eraseVideoLogo(request: EraseVideoLogoRequest): EraseVideoLogoResponse {
  var runtime = new Util.RuntimeOptions{};
  return eraseVideoLogoWithOptions(request, runtime);
}

async function eraseVideoLogoAdvance(request: EraseVideoLogoAdvanceRequest, runtime: Util.RuntimeOptions): EraseVideoLogoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var eraseVideoLogoReq = new EraseVideoLogoRequest{};
  OpenApiUtil.convert(request, eraseVideoLogoReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    eraseVideoLogoReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var eraseVideoLogoResp = eraseVideoLogoWithOptions(eraseVideoLogoReq, runtime);
  return eraseVideoLogoResp;
}

model EraseVideoSubtitlesRequest {
  BH?: float(name='BH', example='0.25'),
  BW?: float(name='BW', example='1'),
  BX?: float(name='BX', example='0'),
  BY?: float(name='BY', example='0.75'),
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4'),
}

model EraseVideoSubtitlesAdvanceRequest {
  BH?: float(name='BH', example='0.25'),
  BW?: float(name='BW', example='1'),
  BX?: float(name='BX', example='0'),
  BY?: float(name='BY', example='0.75'),
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/EraseVideoSubtitles/EraseVideoSubtitles1.mp4'),
}

model EraseVideoSubtitlesResponseBody = {
  data?: {
    videoUrl?: string(name='VideoUrl', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/video-desubtitle/2021-04-13-10/41%3A57-TcFd6Zug7gXwbeqs.mp4?Expires=1618312317&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=LZnGSQ8019%2Br5rcR4vKOaaT2UE****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='CCB082BF-A6B1-4C28-9E49-562EEE7DE639'),
}

model EraseVideoSubtitlesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EraseVideoSubtitlesResponseBody(name='body'),
}

/**
 * @param request EraseVideoSubtitlesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return EraseVideoSubtitlesResponse
 */
async function eraseVideoSubtitlesWithOptions(request: EraseVideoSubtitlesRequest, runtime: Util.RuntimeOptions): EraseVideoSubtitlesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.BH)) {
    body['BH'] = request.BH;
  }
  if (!Util.isUnset(request.BW)) {
    body['BW'] = request.BW;
  }
  if (!Util.isUnset(request.BX)) {
    body['BX'] = request.BX;
  }
  if (!Util.isUnset(request.BY)) {
    body['BY'] = request.BY;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'EraseVideoSubtitles',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request EraseVideoSubtitlesRequest
 * @return EraseVideoSubtitlesResponse
 */
async function eraseVideoSubtitles(request: EraseVideoSubtitlesRequest): EraseVideoSubtitlesResponse {
  var runtime = new Util.RuntimeOptions{};
  return eraseVideoSubtitlesWithOptions(request, runtime);
}

async function eraseVideoSubtitlesAdvance(request: EraseVideoSubtitlesAdvanceRequest, runtime: Util.RuntimeOptions): EraseVideoSubtitlesResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var eraseVideoSubtitlesReq = new EraseVideoSubtitlesRequest{};
  OpenApiUtil.convert(request, eraseVideoSubtitlesReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    eraseVideoSubtitlesReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var eraseVideoSubtitlesResp = eraseVideoSubtitlesWithOptions(eraseVideoSubtitlesReq, runtime);
  return eraseVideoSubtitlesResp;
}

model GenerateHumanAnimeStyleVideoRequest {
  cartoonStyle?: string(name='CartoonStyle', description='This parameter is required.', example='anime'),
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/xxx/eas/EvaluateVideoQuality/123.mp4'),
}

model GenerateHumanAnimeStyleVideoAdvanceRequest {
  cartoonStyle?: string(name='CartoonStyle', description='This parameter is required.', example='anime'),
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test/xxx/eas/EvaluateVideoQuality/123.mp4'),
}

model GenerateHumanAnimeStyleVideoResponseBody = {
  data?: {
    videoUrl?: string(name='VideoUrl', example='http://vibktprfx-prod-prod-xstream-cn-shanghai.oss-cn-shanghai.aliyuncs.com/xstream-framework/upload_result_video_2023-02-10_09.45.55.mp4?Expires=1675995564&amp;OSSAccessKeyId=LTAI4FoLmvQ9urWXgSR****&amp;Signature=aIXTeM4IU4nARjy3SNA3YGhhqj****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='d21a2afa-4d52-4bca-803b-e65028146603'),
}

model GenerateHumanAnimeStyleVideoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GenerateHumanAnimeStyleVideoResponseBody(name='body'),
}

/**
 * @summary 视频人像卡通化
 *
 * @param request GenerateHumanAnimeStyleVideoRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GenerateHumanAnimeStyleVideoResponse
 */
async function generateHumanAnimeStyleVideoWithOptions(request: GenerateHumanAnimeStyleVideoRequest, runtime: Util.RuntimeOptions): GenerateHumanAnimeStyleVideoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.cartoonStyle)) {
    body['CartoonStyle'] = request.cartoonStyle;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GenerateHumanAnimeStyleVideo',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 视频人像卡通化
 *
 * @param request GenerateHumanAnimeStyleVideoRequest
 * @return GenerateHumanAnimeStyleVideoResponse
 */
async function generateHumanAnimeStyleVideo(request: GenerateHumanAnimeStyleVideoRequest): GenerateHumanAnimeStyleVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return generateHumanAnimeStyleVideoWithOptions(request, runtime);
}

async function generateHumanAnimeStyleVideoAdvance(request: GenerateHumanAnimeStyleVideoAdvanceRequest, runtime: Util.RuntimeOptions): GenerateHumanAnimeStyleVideoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var generateHumanAnimeStyleVideoReq = new GenerateHumanAnimeStyleVideoRequest{};
  OpenApiUtil.convert(request, generateHumanAnimeStyleVideoReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    generateHumanAnimeStyleVideoReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var generateHumanAnimeStyleVideoResp = generateHumanAnimeStyleVideoWithOptions(generateHumanAnimeStyleVideoReq, runtime);
  return generateHumanAnimeStyleVideoResp;
}

model GenerateVideoRequest {
  duration?: float(name='Duration', example='10'),
  durationAdaption?: boolean(name='DurationAdaption', example='true'),
  fileList?: [ 
    {
      fileName?: string(name='FileName', description='This parameter is required.', example='1-video1.mp4'),
      fileUrl?: string(name='FileUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/GenerateVideo/1-video1.mp4'),
      type?: string(name='Type', description='This parameter is required.', example='video'),
    }
  ](name='FileList', description='1

This parameter is required.'),
  height?: int32(name='Height', example='640'),
  mute?: boolean(name='Mute', example='true'),
  puzzleEffect?: boolean(name='PuzzleEffect', example='true'),
  scene?: string(name='Scene', example='costume'),
  smartEffect?: boolean(name='SmartEffect', example='true'),
  style?: string(name='Style', example='fast'),
  transitionStyle?: string(name='TransitionStyle', example='brush'),
  width?: int32(name='Width', example='640'),
}

model GenerateVideoAdvanceRequest {
  duration?: float(name='Duration', example='10'),
  durationAdaption?: boolean(name='DurationAdaption', example='true'),
  fileList?: [ 
    {
      fileName?: string(name='FileName', description='This parameter is required.', example='1-video1.mp4'),
      fileUrlObject?: readable(name='FileUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/GenerateVideo/1-video1.mp4'),
      type?: string(name='Type', description='This parameter is required.', example='video'),
    }
  ](name='FileList', description='1

This parameter is required.'),
  height?: int32(name='Height', example='640'),
  mute?: boolean(name='Mute', example='true'),
  puzzleEffect?: boolean(name='PuzzleEffect', example='true'),
  scene?: string(name='Scene', example='costume'),
  smartEffect?: boolean(name='SmartEffect', example='true'),
  style?: string(name='Style', example='fast'),
  transitionStyle?: string(name='TransitionStyle', example='brush'),
  width?: int32(name='Width', example='640'),
}

model GenerateVideoResponseBody = {
  data?: {
    videoCoverUrl?: string(name='VideoCoverUrl', example='http://vibktprfx-prod-prod-aic-vd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/video-gen/2021-05-07-15/B9MGfwxu.mp4?Expires=1620372653&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=F9flL1n5GPYaae0dLl%2F8D%2Bn4j6****'),
    videoUrl?: string(name='VideoUrl', example='http://vibktprfx-prod-prod-aic-vd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/video-gen/2021-05-07-15/B9MGfwxu.jpg?Expires=1620372653&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=djBvGvdJu8bd%2FC%2BVHdg1d57U%2Bu****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='7CB9B663-3EF8-4C9C-A464-FDA2B5F1E3A4'),
}

model GenerateVideoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GenerateVideoResponseBody(name='body'),
}

/**
 * @param request GenerateVideoRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GenerateVideoResponse
 */
async function generateVideoWithOptions(request: GenerateVideoRequest, runtime: Util.RuntimeOptions): GenerateVideoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.duration)) {
    body['Duration'] = request.duration;
  }
  if (!Util.isUnset(request.durationAdaption)) {
    body['DurationAdaption'] = request.durationAdaption;
  }
  if (!Util.isUnset(request.fileList)) {
    body['FileList'] = request.fileList;
  }
  if (!Util.isUnset(request.height)) {
    body['Height'] = request.height;
  }
  if (!Util.isUnset(request.mute)) {
    body['Mute'] = request.mute;
  }
  if (!Util.isUnset(request.puzzleEffect)) {
    body['PuzzleEffect'] = request.puzzleEffect;
  }
  if (!Util.isUnset(request.scene)) {
    body['Scene'] = request.scene;
  }
  if (!Util.isUnset(request.smartEffect)) {
    body['SmartEffect'] = request.smartEffect;
  }
  if (!Util.isUnset(request.style)) {
    body['Style'] = request.style;
  }
  if (!Util.isUnset(request.transitionStyle)) {
    body['TransitionStyle'] = request.transitionStyle;
  }
  if (!Util.isUnset(request.width)) {
    body['Width'] = request.width;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GenerateVideo',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GenerateVideoRequest
 * @return GenerateVideoResponse
 */
async function generateVideo(request: GenerateVideoRequest): GenerateVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return generateVideoWithOptions(request, runtime);
}

async function generateVideoAdvance(request: GenerateVideoAdvanceRequest, runtime: Util.RuntimeOptions): GenerateVideoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var generateVideoReq = new GenerateVideoRequest{};
  OpenApiUtil.convert(request, generateVideoReq);

  if(!Util.isUnset(request.fileList)) {
    var i0 : integer = 0;
    for (var item0 : request.fileList) {
      if(!Util.isUnset(item0.fileUrlObject)) {
        authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
        ossConfig.accessKeyId = authResponse.body.accessKeyId;
        ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
        ossClient = new OSS(ossConfig);

        fileObj = new FileForm.FileField{
          filename = authResponse.body.objectKey,
          content = item0.fileUrlObject,
          contentType = '',
        };
        ossHeader = new OSS.PostObjectRequest.header{
          accessKeyId = authResponse.body.accessKeyId,
          policy = authResponse.body.encodedPolicy,
          signature = authResponse.body.signature,
          key = authResponse.body.objectKey,
          file = fileObj,
          successActionStatus = '201',
        };
        uploadRequest = new OSS.PostObjectRequest{
          bucketName = authResponse.body.bucket,
          header = ossHeader,
        };
        ossClient.postObject(uploadRequest, ossRuntime);
        var tmp : GenerateVideoRequest.fileList = generateVideoReq.fileList[i0];
        tmp.fileUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
        i0 = Number.ltoi(Number.add(Number.itol(i0), Number.itol(1)));
      }
    }
  }
  var generateVideoResp = generateVideoWithOptions(generateVideoReq, runtime);
  return generateVideoResp;
}

model GetAsyncJobResultRequest {
  jobId?: string(name='JobId', description='This parameter is required.', example='E75FE679-0303-4DD1-8252-1143B4FA8A27'),
}

model GetAsyncJobResultResponseBody = {
  data?: {
    errorCode?: string(name='ErrorCode', example='InvalidParameter'),
    errorMessage?: string(name='ErrorMessage', example='paramsIllegal'),
    jobId?: string(name='JobId', example='49E2CC28-ED1D-4CC5-854D-7D0AE2B20976'),
    result?: string(name='Result', example='{\\\\"VideoUrl\\\\":\\\\"http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/video-super-resolution/2020-03-26-02/55%3A59-XFLsuEKpPxleHl4n.mp4?Expires=1585193159&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=OqsxMwAKsFVjPO%2Brgw%2BpXHIm6v****\\\\"}'),
    status?: string(name='Status', example='PROCESS_SUCCESS'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='43A0AEB6-45F4-4138-8E89-E1A5D63200E3'),
}

model GetAsyncJobResultResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetAsyncJobResultResponseBody(name='body'),
}

/**
 * @param request GetAsyncJobResultRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetAsyncJobResultResponse
 */
async function getAsyncJobResultWithOptions(request: GetAsyncJobResultRequest, runtime: Util.RuntimeOptions): GetAsyncJobResultResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetAsyncJobResult',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request GetAsyncJobResultRequest
 * @return GetAsyncJobResultResponse
 */
async function getAsyncJobResult(request: GetAsyncJobResultRequest): GetAsyncJobResultResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAsyncJobResultWithOptions(request, runtime);
}

model InterpolateVideoFrameRequest {
  bitrate?: int32(name='Bitrate', example='30'),
  frameRate?: int32(name='FrameRate', example='70'),
  videoURL?: string(name='VideoURL', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/InterpolateVideoFrame/InterpolateVideoFrame3.mp4'),
}

model InterpolateVideoFrameAdvanceRequest {
  bitrate?: int32(name='Bitrate', example='30'),
  frameRate?: int32(name='FrameRate', example='70'),
  videoURLObject?: readable(name='VideoURL', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/InterpolateVideoFrame/InterpolateVideoFrame3.mp4'),
}

model InterpolateVideoFrameResponseBody = {
  data?: {
    videoURL?: string(name='VideoURL', example='http://vibktprfx-prod-prod-aic-vd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/video-interp/20-12-22/mRsPNVunG7717nne_20-12-22-07-29-51.mp4?Expires=1608624020&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=NFjSLll8E7E1tkuLPFyTpr6ULi****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='7EF85B5B-FB44-4C3E-9B8F-08C6CD912CEB'),
}

model InterpolateVideoFrameResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: InterpolateVideoFrameResponseBody(name='body'),
}

/**
 * @param request InterpolateVideoFrameRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return InterpolateVideoFrameResponse
 */
async function interpolateVideoFrameWithOptions(request: InterpolateVideoFrameRequest, runtime: Util.RuntimeOptions): InterpolateVideoFrameResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.bitrate)) {
    body['Bitrate'] = request.bitrate;
  }
  if (!Util.isUnset(request.frameRate)) {
    body['FrameRate'] = request.frameRate;
  }
  if (!Util.isUnset(request.videoURL)) {
    body['VideoURL'] = request.videoURL;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'InterpolateVideoFrame',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request InterpolateVideoFrameRequest
 * @return InterpolateVideoFrameResponse
 */
async function interpolateVideoFrame(request: InterpolateVideoFrameRequest): InterpolateVideoFrameResponse {
  var runtime = new Util.RuntimeOptions{};
  return interpolateVideoFrameWithOptions(request, runtime);
}

async function interpolateVideoFrameAdvance(request: InterpolateVideoFrameAdvanceRequest, runtime: Util.RuntimeOptions): InterpolateVideoFrameResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var interpolateVideoFrameReq = new InterpolateVideoFrameRequest{};
  OpenApiUtil.convert(request, interpolateVideoFrameReq);

  if(!Util.isUnset(request.videoURLObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoURLObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    interpolateVideoFrameReq.videoURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var interpolateVideoFrameResp = interpolateVideoFrameWithOptions(interpolateVideoFrameReq, runtime);
  return interpolateVideoFrameResp;
}

model MergeVideoFaceRequest {
  addWatermark?: boolean(name='AddWatermark'),
  enhance?: boolean(name='Enhance'),
  referenceURL?: string(name='ReferenceURL', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/MergeVideoFace/MergeVideoFace-pic1.png'),
  videoURL?: string(name='VideoURL', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/MergeVideoFace/MergeVideoFace1.mp4'),
  watermarkType?: string(name='WatermarkType'),
}

model MergeVideoFaceAdvanceRequest {
  addWatermark?: boolean(name='AddWatermark'),
  enhance?: boolean(name='Enhance'),
  referenceURLObject?: readable(name='ReferenceURL', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/MergeVideoFace/MergeVideoFace-pic1.png'),
  videoURLObject?: readable(name='VideoURL', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/MergeVideoFace/MergeVideoFace1.mp4'),
  watermarkType?: string(name='WatermarkType'),
}

model MergeVideoFaceResponseBody = {
  data?: {
    videoURL?: string(name='VideoURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/video-face-fusion/A657011C-82B4-4705-A5DB-69B18B7CE89D.mp4?Expires=1606378308&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=Hl3cq5XedTGCscOSr0OGVxAS2o****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='DEF90E76-B62D-45EF-8835-CA3C83842B18'),
}

model MergeVideoFaceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: MergeVideoFaceResponseBody(name='body'),
}

/**
 * @param request MergeVideoFaceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return MergeVideoFaceResponse
 */
async function mergeVideoFaceWithOptions(request: MergeVideoFaceRequest, runtime: Util.RuntimeOptions): MergeVideoFaceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.addWatermark)) {
    body['AddWatermark'] = request.addWatermark;
  }
  if (!Util.isUnset(request.enhance)) {
    body['Enhance'] = request.enhance;
  }
  if (!Util.isUnset(request.referenceURL)) {
    body['ReferenceURL'] = request.referenceURL;
  }
  if (!Util.isUnset(request.videoURL)) {
    body['VideoURL'] = request.videoURL;
  }
  if (!Util.isUnset(request.watermarkType)) {
    body['WatermarkType'] = request.watermarkType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'MergeVideoFace',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request MergeVideoFaceRequest
 * @return MergeVideoFaceResponse
 */
async function mergeVideoFace(request: MergeVideoFaceRequest): MergeVideoFaceResponse {
  var runtime = new Util.RuntimeOptions{};
  return mergeVideoFaceWithOptions(request, runtime);
}

async function mergeVideoFaceAdvance(request: MergeVideoFaceAdvanceRequest, runtime: Util.RuntimeOptions): MergeVideoFaceResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var mergeVideoFaceReq = new MergeVideoFaceRequest{};
  OpenApiUtil.convert(request, mergeVideoFaceReq);

  if(!Util.isUnset(request.referenceURLObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.referenceURLObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    mergeVideoFaceReq.referenceURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  if(!Util.isUnset(request.videoURLObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoURLObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    mergeVideoFaceReq.videoURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var mergeVideoFaceResp = mergeVideoFaceWithOptions(mergeVideoFaceReq, runtime);
  return mergeVideoFaceResp;
}

model MergeVideoModelFaceRequest {
  addWatermark?: boolean(name='AddWatermark'),
  enhance?: boolean(name='Enhance'),
  faceImageURL?: string(name='FaceImageURL', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/ref/ref.jpg'),
  mergeInfos?: [ 
    {
      imageURL?: string(name='ImageURL'),
      templateFaceID?: string(name='TemplateFaceID'),
      templateFaceURL?: string(name='TemplateFaceURL'),
    }
  ](name='MergeInfos'),
  templateId?: string(name='TemplateId', description='This parameter is required.', example='3bf2418c-7adf-4002-a9d6-2f7cf1889c0d'),
  watermarkType?: string(name='WatermarkType'),
}

model MergeVideoModelFaceAdvanceRequest {
  addWatermark?: boolean(name='AddWatermark'),
  enhance?: boolean(name='Enhance'),
  faceImageURLObject?: readable(name='FaceImageURL', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/ref/ref.jpg'),
  mergeInfos?: [ 
    {
      imageURL?: string(name='ImageURL'),
      templateFaceID?: string(name='TemplateFaceID'),
      templateFaceURL?: string(name='TemplateFaceURL'),
    }
  ](name='MergeInfos'),
  templateId?: string(name='TemplateId', description='This parameter is required.', example='3bf2418c-7adf-4002-a9d6-2f7cf1889c0d'),
  watermarkType?: string(name='WatermarkType'),
}

model MergeVideoModelFaceResponseBody = {
  data?: {
    videoURL?: string(name='VideoURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/video-face-fusion/334F180F-3B50-51CB-B4CB-9A86A542D3BC-5716-20210906-074905.mp4?Expires=1630916420&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=OEtNqVYxXRwkyO4BrsYVJ8q5bx****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='334F180F-3B50-51CB-B4CB-9A86A542D3BC'),
}

model MergeVideoModelFaceResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: MergeVideoModelFaceResponseBody(name='body'),
}

/**
 * @summary 视频模板融合换脸
 *
 * @param request MergeVideoModelFaceRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return MergeVideoModelFaceResponse
 */
async function mergeVideoModelFaceWithOptions(request: MergeVideoModelFaceRequest, runtime: Util.RuntimeOptions): MergeVideoModelFaceResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.addWatermark)) {
    body['AddWatermark'] = request.addWatermark;
  }
  if (!Util.isUnset(request.enhance)) {
    body['Enhance'] = request.enhance;
  }
  if (!Util.isUnset(request.faceImageURL)) {
    body['FaceImageURL'] = request.faceImageURL;
  }
  if (!Util.isUnset(request.mergeInfos)) {
    body['MergeInfos'] = request.mergeInfos;
  }
  if (!Util.isUnset(request.templateId)) {
    body['TemplateId'] = request.templateId;
  }
  if (!Util.isUnset(request.watermarkType)) {
    body['WatermarkType'] = request.watermarkType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'MergeVideoModelFace',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 视频模板融合换脸
 *
 * @param request MergeVideoModelFaceRequest
 * @return MergeVideoModelFaceResponse
 */
async function mergeVideoModelFace(request: MergeVideoModelFaceRequest): MergeVideoModelFaceResponse {
  var runtime = new Util.RuntimeOptions{};
  return mergeVideoModelFaceWithOptions(request, runtime);
}

async function mergeVideoModelFaceAdvance(request: MergeVideoModelFaceAdvanceRequest, runtime: Util.RuntimeOptions): MergeVideoModelFaceResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var mergeVideoModelFaceReq = new MergeVideoModelFaceRequest{};
  OpenApiUtil.convert(request, mergeVideoModelFaceReq);

  if(!Util.isUnset(request.faceImageURLObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.faceImageURLObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    mergeVideoModelFaceReq.faceImageURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var mergeVideoModelFaceResp = mergeVideoModelFaceWithOptions(mergeVideoModelFaceReq, runtime);
  return mergeVideoModelFaceResp;
}

model QueryFaceVideoTemplateRequest {
  pageNo?: long(name='PageNo'),
  pageSize?: long(name='PageSize', example='100'),
  templateId?: string(name='TemplateId', example='3bf2418c-7adf-4002-a9d6-2f7cf1889c0d'),
}

model QueryFaceVideoTemplateResponseBody = {
  data?: {
    elements?: [ 
      {
        createTime?: string(name='CreateTime', example='2021-09-06 15:17:19'),
        faceInfos?: [ 
          {
            templateFaceID?: string(name='TemplateFaceID'),
            templateFaceURL?: string(name='TemplateFaceURL'),
          }
        ](name='FaceInfos'),
        templateId?: string(name='TemplateId', example='3bf2418c-7adf-4002-a9d6-2f7cf1889c0d'),
        templateURL?: string(name='TemplateURL', example='http://vibktprfx-prod-prod-aic-gd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/image-face-fusion/OriginUrl/user/2021-09-06/e4d6ecf6-8dc8-4dac-acb5-56a737ccbc06?Expires=1630914551&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=kBcLm66y7%2FZ3eIMgwXJg1zNP7k****'),
        updateTime?: string(name='UpdateTime', example='2021-09-06 15:18:15'),
        userId?: string(name='UserId', example='zhangsan'),
      }
    ](name='Elements'),
    total?: long(name='Total'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='A06E3D21-890D-500B-97DA-D8B99D2DDDC4'),
}

model QueryFaceVideoTemplateResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: QueryFaceVideoTemplateResponseBody(name='body'),
}

/**
 * @summary 视频人脸融合模板查询
 *
 * @param request QueryFaceVideoTemplateRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return QueryFaceVideoTemplateResponse
 */
async function queryFaceVideoTemplateWithOptions(request: QueryFaceVideoTemplateRequest, runtime: Util.RuntimeOptions): QueryFaceVideoTemplateResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.templateId)) {
    query['TemplateId'] = request.templateId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryFaceVideoTemplate',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 视频人脸融合模板查询
 *
 * @param request QueryFaceVideoTemplateRequest
 * @return QueryFaceVideoTemplateResponse
 */
async function queryFaceVideoTemplate(request: QueryFaceVideoTemplateRequest): QueryFaceVideoTemplateResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryFaceVideoTemplateWithOptions(request, runtime);
}

model ReduceVideoNoiseRequest {
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxx/shang/video/SD%289516100%29.mp4'),
}

model ReduceVideoNoiseAdvanceRequest {
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xxx/shang/video/SD%289516100%29.mp4'),
}

model ReduceVideoNoiseResponseBody = {
  data?: {
    videoUrl?: string(name='VideoUrl', example='http://vibktprfx-prod-prod-xstream-cn-shanghai.oss-cn-shanghai.aliyuncs.com/xstream-framework/upload_result_video_2023-02-10_09.45.55.mp4?Expires=1675995564&amp;OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&amp;Signature=aIXTeM4IU4nARjy3SNA3YGhhqj****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='d21a2afa-4d52-4bca-803b-e65028146603'),
}

model ReduceVideoNoiseResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ReduceVideoNoiseResponseBody(name='body'),
}

/**
 * @summary 视频降噪
 *
 * @param request ReduceVideoNoiseRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ReduceVideoNoiseResponse
 */
async function reduceVideoNoiseWithOptions(request: ReduceVideoNoiseRequest, runtime: Util.RuntimeOptions): ReduceVideoNoiseResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ReduceVideoNoise',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 视频降噪
 *
 * @param request ReduceVideoNoiseRequest
 * @return ReduceVideoNoiseResponse
 */
async function reduceVideoNoise(request: ReduceVideoNoiseRequest): ReduceVideoNoiseResponse {
  var runtime = new Util.RuntimeOptions{};
  return reduceVideoNoiseWithOptions(request, runtime);
}

async function reduceVideoNoiseAdvance(request: ReduceVideoNoiseAdvanceRequest, runtime: Util.RuntimeOptions): ReduceVideoNoiseResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var reduceVideoNoiseReq = new ReduceVideoNoiseRequest{};
  OpenApiUtil.convert(request, reduceVideoNoiseReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    reduceVideoNoiseReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var reduceVideoNoiseResp = reduceVideoNoiseWithOptions(reduceVideoNoiseReq, runtime);
  return reduceVideoNoiseResp;
}

model SuperResolveVideoRequest {
  bitRate?: int32(name='BitRate', example='5'),
  videoUrl?: string(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/SuperResolveVideo/SuperResolveVideo2.mp4'),
}

model SuperResolveVideoAdvanceRequest {
  bitRate?: int32(name='BitRate', example='5'),
  videoUrlObject?: readable(name='VideoUrl', description='This parameter is required.', example='http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/videoenhan/SuperResolveVideo/SuperResolveVideo2.mp4'),
}

model SuperResolveVideoResponseBody = {
  data?: {
    videoUrl?: string(name='VideoUrl', example='http://algo-app-aic-vd-cn-shanghai-prod.oss-cn-shanghai.aliyuncs.com/video-super-resolution/2020-03-20-12/12%3A11-UlLVELFzIy5EAyEh.mp4?Expires=1584708132&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=0V8yKrCVybC4KIPtRuGKJDJaQT****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='186AC396-0EEC-46F1-AAA1-BF3585227427'),
}

model SuperResolveVideoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SuperResolveVideoResponseBody(name='body'),
}

/**
 * @param request SuperResolveVideoRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SuperResolveVideoResponse
 */
async function superResolveVideoWithOptions(request: SuperResolveVideoRequest, runtime: Util.RuntimeOptions): SuperResolveVideoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.bitRate)) {
    body['BitRate'] = request.bitRate;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'SuperResolveVideo',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request SuperResolveVideoRequest
 * @return SuperResolveVideoResponse
 */
async function superResolveVideo(request: SuperResolveVideoRequest): SuperResolveVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return superResolveVideoWithOptions(request, runtime);
}

async function superResolveVideoAdvance(request: SuperResolveVideoAdvanceRequest, runtime: Util.RuntimeOptions): SuperResolveVideoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var superResolveVideoReq = new SuperResolveVideoRequest{};
  OpenApiUtil.convert(request, superResolveVideoReq);

  if(!Util.isUnset(request.videoUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    superResolveVideoReq.videoUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var superResolveVideoResp = superResolveVideoWithOptions(superResolveVideoReq, runtime);
  return superResolveVideoResp;
}

model ToneSdrVideoRequest {
  bitrate?: int32(name='Bitrate', example='30'),
  recolorModel?: string(name='RecolorModel', example='auto_l2'),
  videoURL?: string(name='VideoURL', description='This parameter is required.', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/test_for_api/xxxx.mp4'),
}

model ToneSdrVideoAdvanceRequest {
  bitrate?: int32(name='Bitrate', example='30'),
  recolorModel?: string(name='RecolorModel', example='auto_l2'),
  videoURLObject?: readable(name='VideoURL', description='This parameter is required.', example='https://invi-label.oss-cn-shanghai.aliyuncs.com/label/temp/faceswap/test_for_api/xxxx.mp4'),
}

model ToneSdrVideoResponseBody = {
  data?: {
    videoURL?: string(name='VideoURL', example='http://vibktprfx-prod-prod-aic-vd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/sdr-color-enhance/20-12-22/SxBKgwBhlObusG20_20-12-22-07-59-45.mp4?Expires=1608625795&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRp****&Signature=maoOZ52y7U9ZuL2KqI0IfGq8%2FR****'),
  }(name='Data'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', example='89B5AFF1-8A64-4F76-B391-56AD7D22DE35'),
}

model ToneSdrVideoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ToneSdrVideoResponseBody(name='body'),
}

/**
 * @param request ToneSdrVideoRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return ToneSdrVideoResponse
 */
async function toneSdrVideoWithOptions(request: ToneSdrVideoRequest, runtime: Util.RuntimeOptions): ToneSdrVideoResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.bitrate)) {
    body['Bitrate'] = request.bitrate;
  }
  if (!Util.isUnset(request.recolorModel)) {
    body['RecolorModel'] = request.recolorModel;
  }
  if (!Util.isUnset(request.videoURL)) {
    body['VideoURL'] = request.videoURL;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ToneSdrVideo',
    version = '2020-03-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @param request ToneSdrVideoRequest
 * @return ToneSdrVideoResponse
 */
async function toneSdrVideo(request: ToneSdrVideoRequest): ToneSdrVideoResponse {
  var runtime = new Util.RuntimeOptions{};
  return toneSdrVideoWithOptions(request, runtime);
}

async function toneSdrVideoAdvance(request: ToneSdrVideoAdvanceRequest, runtime: Util.RuntimeOptions): ToneSdrVideoResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.empty(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videoenhan',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var toneSdrVideoReq = new ToneSdrVideoRequest{};
  OpenApiUtil.convert(request, toneSdrVideoReq);

  if(!Util.isUnset(request.videoURLObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoURLObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    toneSdrVideoReq.videoURL = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var toneSdrVideoResp = toneSdrVideoWithOptions(toneSdrVideoReq, runtime);
  return toneSdrVideoResp;
}

